package com.dd.admin.business.sellDetail.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dd.admin.common.consts.MemberShopConst;
import com.dd.admin.common.model.PageFactory;
import com.dd.admin.business.sellDetail.entity.SellDetail;
import com.dd.admin.business.sellDetail.mapper.SellDetailMapper;
import com.dd.admin.business.sellDetail.service.SellDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.dd.admin.business.sellDetail.domain.SellDetailVo;
import com.dd.admin.business.sellDetail.domain.SellDetailDto;
import java.util.List;

/**
 * <p>
 * 订单详情 服务实现类
 * </p>
 *
 * @author 727869402@qq.com
 * @since 2024-06-19
 */
@Service
public class SellDetailServiceImpl extends ServiceImpl<SellDetailMapper, SellDetail> implements SellDetailService {

    @Override
    public IPage<SellDetailVo> selectSellDetailPage(SellDetailDto sellDetailDto) {
        Page page = PageFactory.defaultPage();
        return baseMapper.selectSellDetailPage(page,sellDetailDto);
    }

    @Override
    public List<SellDetailVo> selectSellDetailList(SellDetailDto sellDetailDto) {
        return baseMapper.selectSellDetailList(sellDetailDto);
    }

    @Override
    public List<SellDetail> selectSellDetailList(List<String> sellIds) {
        LambdaQueryWrapper<SellDetail> selldetailQueryWrapper = new LambdaQueryWrapper<>();
        if(CollectionUtil.isNotEmpty(sellIds)){
            selldetailQueryWrapper.in(SellDetail::getSellId, sellIds);
        }
        List<SellDetail> sellDetailList = this.list(selldetailQueryWrapper);
        return sellDetailList;
    }

    @Override
    public List<SellDetail> selectSellDetailList(String sellId) {
        LambdaQueryWrapper<SellDetail> selldetailQueryWrapper = new LambdaQueryWrapper<>();
        selldetailQueryWrapper.eq(SellDetail::getSellId, sellId);
        List<SellDetail> sellDetailList = this.list(selldetailQueryWrapper);
        return sellDetailList;
    }

    @Override
    public void updateSellDetailStatus(String sellId) {
        baseMapper.updateSellDetailStatus(sellId);
    }

    @Override
    public List<SellDetailVo> productProportion(String shopId, Integer limit) {
        return baseMapper.productProportion(shopId,limit);
    }



}
